#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>

int* decrypt(int* code, int codeSize, int k, int* returnSize) {
    int n = codeSize;
    *returnSize = n;
    int* ans = (int*)malloc(sizeof(int) * n);
    int i = 0;
    if (k == 0)
    {
        for (i = 0; i < n; i++)
        {
            ans[i] = 0;
        }
        return ans;
    }
    int k1 = 0;
    int flg = 1;
    if (k < 0)
        flg *= -1;
    for (i = 0; i < n; i++)
    {
        k1 = abs(k);
        int sum = 0;
        while (k1)
        {
            sum += code[(i + (k1 * flg) + n) % n];
            k1--;
        }
        ans[i] = sum;
    }
    return ans;
}


int main()
{
    int size = 0;
    int nums[] = { 5,7,1,4 };
    decrypt(nums,4,3,&size);
    return 0;
}












